# __init__.py :初始化文件，创建flask应用
from flask import Flask
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from exts import init_exts

def create_app():
    # 创建flask应用并返回app
    app = Flask(__name__)
    
    # 配置数据库
    db_uri = 'sqlite:///sqlite3.db'
    app.config['SQLALCHEMY_DATABASE_URI'] = db_uri
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False # 禁止对象追踪修改
    
    # 初始化插件
    init_exts(app)
    
    # 注册蓝图
    from .views import blue
    app.register_blueprint(blueprint=blue)
    
    return app